package com.egg.ylt.adapter;

import android.content.Context;
import android.widget.TextView;

import com.egg.ylt.R;
import com.egg.ylt.Utils.StringSpanUtils;
import com.egg.ylt.Utils.StringUtil;
import com.egg.ylt.pojo.SwimHistoryListEntity;
import com.yonyou.framework.library.adapter.rv.CommonAdapter;
import com.yonyou.framework.library.adapter.rv.ViewHolder;

/**
 * author:        yupeng
 * created on:    2019/2/23 18:01
 * description:   游泳纪录列表adapter
 */
public class ADA_SwimHistoryList extends CommonAdapter<SwimHistoryListEntity.ListBean> {
    private Context context;

    public ADA_SwimHistoryList(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    protected int itemLayoutId() {
        return R.layout.item_swim_history;
    }

    @Override
    protected void convert(ViewHolder holder, SwimHistoryListEntity.ListBean listBean, int position) {
        holder.setText(R.id.date_record_txt, StringUtil.get(listBean.getDate()));
        holder.setText(R.id.day_record_txt, StringUtil.get(listBean.getWeek()));
        holder.setText(R.id.address_record_txt, StringUtil.get(listBean.getShopName()));

        // 设备类型：3-抚触台；4-游泳
        if ("3".equals(listBean.getType())) { // 抚触台

            ((TextView)holder.getView(R.id.detail_record_txt)).setText(StringSpanUtils.init()
                    .addForegroundColorHighLight(context.getResources().getColor(R.color.record_date_gray_666),"测量身高")
                    .addForegroundColorHighLight(context.getResources().getColor(R.color.color_FFB024),listBean.getHeight())
                    .addForegroundColorHighLight(context.getResources().getColor(R.color.record_date_gray_666),"cm，体重")
                    .addForegroundColorHighLight(context.getResources().getColor(R.color.color_FFB024),listBean.getWeight())
                    .addForegroundColorHighLight(context.getResources().getColor(R.color.record_date_gray_666),"kg").build());

        } else if ("4".equals(listBean.getType())) { // 游泳

            ((TextView)holder.getView(R.id.detail_record_txt)).setText(StringSpanUtils.init()
                    .addForegroundColorHighLight(context.getResources().getColor(R.color.record_date_gray_666),"累计时长")
                    .addForegroundColorHighLight(context.getResources().getColor(R.color.color_FFB024),listBean.getTimeLength())
                    .addForegroundColorHighLight(context.getResources().getColor(R.color.record_date_gray_666),"分钟，消耗")
                    .addForegroundColorHighLight(context.getResources().getColor(R.color.color_FFB024),listBean.getCalories())
                    .addForegroundColorHighLight(context.getResources().getColor(R.color.record_date_gray_666),"千卡").build());
        }
    }
}
